<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type='file' accept='text/plain' onchange='openFile(event)'><br>
    <div id="output"></div>
</body>

<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
let arr=[];
let i=0;

    function myDemo(){
        i++;
        // console.log(arr)
        let res=arr.split("\n");
        let t=document.createTextNode(res[i])
                    let a=document.createElement("br")

        document.getElementById("output").append(t)
        document.getElementById("output").append(a)



    }
    var openFile = function(event) {
        var input = event.target;
        var reader = new FileReader();
        reader.onload = function() {
            if(reader.result) {
                //显示文件内容
                arr=reader.result;
                console.log(arr);
                let res=arr.split("\n");
                // res.forEach(element => {
                //     let t=document.createTextNode(element)
                //     let a=document.createElement("br")
                //     document.getElementById("output").append(t)
                //     document.getElementById("output").append(a)
                // });
                // console.log(res)
            }

        };
        reader.readAsText(input.files[0]);

   
    };


  
setInterval(myDemo,"1000")
</script>


</html>